package com.bdqn.websocket1.controller;

import com.bdqn.websocket1.pojo.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Controller;

@Controller
public class MessageController {
    @Autowired
    private SimpMessagingTemplate simpMessagingTemplate;

    @MessageMapping("/sendAll")
    public void sendAll(Message message) {
        simpMessagingTemplate.convertAndSend("/topic/receiveAll", message);
    }
}
